﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		Referrer.Builder.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            Referrer.Builder.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion
 

using System;
using Topics.Radical.Validation;

namespace Dexter.Domain.Model {
	public partial class Referrer {
		/// <summary>
		/// Creates a new instance of <see cref="Referrer"/>.
		/// </summary>
		/// <param name="url">The URL.</param>
		/// <param name="referrerUrl">The referrer URL.</param>
		/// <returns>
		/// A new instance of <see cref="Referrer"/>
		/// </returns>
		/// <exception cref="ArgumentNullException"> If <paramref name="url"/> is <c>null</c> .</exception>
		/// <exception cref="ArgumentNullException"> If <paramref name="referrerUrl"/> is <c>null</c>.</exception>
		public static Referrer CreateNewReferrer ( Uri url , Uri referrerUrl ) {
			Ensure.That ( url )
				.Named ( "url" )
				.WithPreview ( ( v , e ) => Logger.Warn ( v.GetFullErrorMessage ( ) , e ) )
				.IsNotNull ( );

			Ensure.That ( url )
				.Named ( "referrerUrl" )
				.WithPreview ( ( v , e ) => Logger.Warn ( v.GetFullErrorMessage ( ) , e ) )
				.IsNotNull ( );


			return new Referrer ( url , referrerUrl );
		}
	}
}
